package com.nit.mapper;

import com.nit.dto.MemberDTO;
import com.nit.entity.MemberEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface MemberMapper {

    @Select("SELECT member_id, member_name, member_phone, member_email, is_enable, gmt_create " +
            "FROM tb_member " +
            "WHERE " +
            "member_name LIKE CONCAT('%', #{memberName}, '%') " +
            "AND is_delete = 0 ")
    List<MemberDTO> query(@Param("memberName") String memberName);


    @Update("UPDATE tb_member " +
            "SET is_enable = 1 - is_enable" +
            "WHERE member_id = #{memberId} ")
    Integer change(@Param("memberId") Long memberId);

    @Update("UPDATE tb_member " +
            "SET is_delete = 1 " +
            "WHERE member_id = #{memberId} ")
    Integer remove(@Param("memberId") Long memberId);

//    @Insert("INSERT INTO " +
//            "tb_member (" +
//            "member_name, member_email, " +
//            "member_phone, member_image, " +
//            "is_delete, gmt_create " +
//            "is_enable)" +
//            "VALUES (" +
//            "#{memberEntity.memberName}, #{memberEntity.memberEmail}, " +
//            "#{memberEntity.memberPhone}, #{memberEntity.memberImage}, " +
//            "0, #{goodsEntity.gmtCreate}," +
//            "0")
//    @Options(useGeneratedKeys = true, keyProperty = "memberId", keyColumn = "member_id")
//    Integer add(@Param("memberEntity") MemberEntity memberEntity);
}
